package services

import (
	"github.com/mlogclub/simple/sqls"
	"github.com/mlogclub/simple/web/params"

	"bbs-go/internal/models"
	"bbs-go/internal/repositories"
)

var ApprovalProcessNodesService = newApprovalProcessNodesService()

func newApprovalProcessNodesService() *approvalProcessNodesService {
	return &approvalProcessNodesService{}
}

type approvalProcessNodesService struct {
}

func (s *approvalProcessNodesService) Get(id int64) *models.ApprovalProcessNodes {
	return repositories.ApprovalProcessNodesRepository.Get(sqls.DB(), id)
}

func (s *approvalProcessNodesService) Take(where ...interface{}) *models.ApprovalProcessNodes {
	return repositories.ApprovalProcessNodesRepository.Take(sqls.DB(), where...)
}

func (s *approvalProcessNodesService) Find(cnd *sqls.Cnd) []models.ApprovalProcessNodes {
	return repositories.ApprovalProcessNodesRepository.Find(sqls.DB(), cnd)
}

func (s *approvalProcessNodesService) FindPageByParams(params *params.QueryParams) (list []models.ApprovalProcessNodes, paging *sqls.Paging) {
	return repositories.ApprovalProcessNodesRepository.FindPageByParams(sqls.DB(), params)
}

func (s *approvalProcessNodesService) FindPageByCnd(cnd *sqls.Cnd) (list []models.ApprovalProcessNodes, paging *sqls.Paging) {
	return repositories.ApprovalProcessNodesRepository.FindPageByCnd(sqls.DB(), cnd)
}

func (s *approvalProcessNodesService) Create(t *models.ApprovalProcessNodes) error {
	return repositories.ApprovalProcessNodesRepository.Create(sqls.DB(), t)
}

func (s *approvalProcessNodesService) Update(t *models.ApprovalProcessNodes) error {
	return repositories.ApprovalProcessNodesRepository.Update(sqls.DB(), t)
}

func (s *approvalProcessNodesService) Updates(id int64, columns map[string]interface{}) error {
	return repositories.ApprovalProcessNodesRepository.Updates(sqls.DB(), id, columns)
}

func (s *approvalProcessNodesService) UpdateColumn(id int64, name string, value interface{}) error {
	return repositories.ApprovalProcessNodesRepository.UpdateColumn(sqls.DB(), id, name, value)
}
